﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoParsers.CustomExceptions;
using DL;

namespace AutoParsers
{
    public class ParseService
    {
        public ParsedCar ParseCar(string url)
        {
            var type = GetParserType(url);
            IAutoParser parserClass;
            switch (type)
            {
                case Parser.AUTO:
                    parserClass = new AutoGeParser();
                    break;
                case Parser.MYAUTO:
                    parserClass = new MyAutoGeParser();
                    break;
                case Parser.MYCAR:
                    parserClass = new MyCarGeParser();
                    break;
                //case Parser.CAR:
                //    parserClass = new CarGeParser();
                //    break;
                case Parser.UNKNOWN:
                    throw new UnknownUrlException();
                    break;
                default:
                    throw new InvalidUrlException();
                    break;
            }
            return parserClass.ParseAuto(url);
        }

        private Parser GetParserType(string url)
        {
            //TODO implement function
            // if host is not known throw UnknownUrlException
            throw new NotImplementedException();
        }
    }

    public enum Parser
    {
        AUTO,
        MYAUTO,
        MYCAR,
        CAR,
        UNKNOWN
    }
}
